Skip to content

Conversation

@seer-by-sentry
Copy link
Contributor

Fix: Add null checks to OpenPath methods to prevent NRE

Resolved / Related Issues

To prevent extra work, all changes to the Files codebase must link to an approved issue marked as Ready to build. Please insert the issue number following the hashtag with the issue number that this Pull Request resolves.

  • Closes #

Fixes FILES-APP-2MN. The issue was that: Asynchronous execution of OpenPath allows associatedInstance.ShellViewModel to become null before subsequent access, causing NullReferenceException.

  • Added null checks for associatedInstance.ShellViewModel in OpenSelectedItemsAsync and OpenItemsWithExecutableAsync.
  • Implemented comprehensive null checks for associatedInstance.ShellViewModel throughout the OpenPath method to prevent potential crashes during navigation.

This fix was generated by Seer in Sentry, triggered by Yair. 👁️ Run ID: 7531953

Not quite right? Click here to continue debugging with Seer.

Steps used to test these changes

Stability is a top priority for Files and all changes are required to go through testing before being merged into the repo. Please include a list of steps that you used to test this PR.

  1. Attempt to reproduce the NRE by rapidly opening paths/items asynchronously.
  2. Verify that opening selected items (OpenSelectedItemsAsync) and items with executables (OpenItemsWithExecutableAsync) functions correctly without crashing.
  3. Verify general navigation using OpenPath remains stable and does not throw NullReferenceException.

@yaira2 yaira2 added the ready for review Pull requests that are ready for review label Dec 15, 2025
@yaira2 yaira2 requested a review from hishitetsu December 22, 2025 21:01
Copy link
Member

@hishitetsu hishitetsu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's better to reuse the instance that has been verified as non-null rather than checking for non-null every time.

@yaira2 yaira2 marked this pull request as draft December 23, 2025 15:39
@yaira2 yaira2 requested a review from hishitetsu December 23, 2025 17:26
@yaira2 yaira2 marked this pull request as ready for review December 23, 2025 17:26
@yaira2 yaira2 added ready to merge Pull requests that are approved and ready to merge and removed ready for review Pull requests that are ready for review labels Dec 24, 2025
@yaira2 yaira2 merged commit e21ef88 into main Dec 24, 2025
9 checks passed
@yaira2 yaira2 deleted the seer/fix/shellviewmodel-null-checks branch December 24, 2025 00:46
@yaira2
Copy link
Member

yaira2 commented Dec 24, 2025

@hishitetsu thank you for the review.

yaira2 added a commit to Anoop-2024si96509/Files that referenced this pull request Jan 6, 2026
commit 13385cb
Author: Anoop-2024si96509 <[email protected]>
Date:   Tue Jan 6 00:36:45 2026 +0530

    Fix: Fixed an issue where file types displayed differently for hidden items (files-community#18018)

commit 124e1fc
Author: Saravanan G <[email protected]>
Date:   Mon Jan 5 21:29:05 2026 +0530

    Fix: Fixed an issue where search didn't work for tags with spaces in their name (files-community#18020)

commit c1484c2
Author: Steve <[email protected]>
Date:   Mon Jan 5 00:54:06 2026 +0900

    Code Quality: Cleanup warnings (files-community#18011)

    Signed-off-by: Steve <[email protected]>
    Co-authored-by: Copilot <[email protected]>
    Co-authored-by: Copilot <[email protected]>

commit 528be10
Author: Saravanan G <[email protected]>
Date:   Thu Jan 1 01:49:38 2026 +0530

    Fix: Prevent "Failed to enqueue the operation" exception during shutdown (files-community#18006)

commit babc715
Author: 0x5BFA <[email protected]>
Date:   Mon Dec 29 07:27:11 2025 +0900

    Code Quality: Suppress exceptions that can occur in SidebarView drag/drop event handlers (files-community#17996)

commit 01ddde9
Author: Yair <[email protected]>
Date:   Thu Dec 25 16:38:12 2025 -0500

    Build: v4.0.24

commit 3ad75f1
Author: Yair <[email protected]>
Date:   Thu Dec 25 16:37:34 2025 -0500

    Code Quality: Updated translations (files-community#17997)

commit e21ef88
Author: seer-by-sentry[bot] <157164994+seer-by-sentry[bot]@users.noreply.github.com>
Date:   Tue Dec 23 19:46:54 2025 -0500

    Fix: Added null checks for ShellViewModel in navigation helpers (files-community#17963)

    Signed-off-by: Yair <[email protected]>
    Co-authored-by: seer-by-sentry[bot] <157164994+seer-by-sentry[bot]@users.noreply.github.com>
    Co-authored-by: Yair <[email protected]>
    Co-authored-by: hishitetsu <[email protected]>

commit 25bdcd1
Author: Yair <[email protected]>
Date:   Mon Dec 22 18:32:10 2025 -0500

    Build: v4.0.23

commit 6721e58
Author: Yair <[email protected]>
Date:   Mon Dec 22 18:27:25 2025 -0500

    Code Quality: Updated translations (files-community#17986)

commit 0c21660
Author: Yair <[email protected]>
Date:   Mon Dec 22 17:47:00 2025 -0500

    Feature: Added text wrapping to Status Center (files-community#17985)

commit 9afe596
Author: 0x5BFA <[email protected]>
Date:   Tue Dec 23 01:43:23 2025 +0900

    Code Quality: Removed ISidebarViewModel (files-community#17972)

commit 347c35d
Author: 0x5BFA <[email protected]>
Date:   Sun Dec 21 08:40:37 2025 +0900

    GitHub: Removed the extra link space between the download badges (files-community#17975)

commit bb05ce1
Author: Saravanan G <[email protected]>
Date:   Fri Dec 19 20:53:32 2025 +0530

    Feature: Added Copy functionality to sidebar and home page widgets (files-community#17969)

commit 472347c
Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Date:   Thu Dec 18 10:45:37 2025 -0500

    Bump Microsoft.WindowsAppSDK from 1.8.250907003 to 1.8.251106002 (files-community#17974)

    Signed-off-by: dependabot[bot] <[email protected]>
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

commit 81aa50c
Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Date:   Thu Dec 18 10:45:27 2025 -0500

    Bump Microsoft.Windows.SDK.BuildTools from 10.0.26100.4948 to 10.0.26100.7175 (files-community#17973)

    Signed-off-by: dependabot[bot] <[email protected]>
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

commit e49e479
Author: 0x5BFA <[email protected]>
Date:   Thu Dec 18 02:55:24 2025 +0900

    Feature: Added theme shadow to Omnibar flyout (files-community#17971)

commit 1d66171
Author: Marlen Halvorsen <[email protected]>
Date:   Wed Dec 17 00:53:29 2025 +0100

    Feature: Added default name when creating new files (files-community#17942)

    Co-authored-by: Yair <[email protected]>

commit 014d34d
Author: Saravanan G <[email protected]>
Date:   Tue Dec 16 21:01:41 2025 +0530

    Code Quality: Additional logs to troubleshoot crashes (files-community#17955)

commit f56c965
Author: Yair <[email protected]>
Date:   Mon Dec 15 12:18:46 2025 -0500

    Code Quality: Change provider detection order in PreviewPopupService

    Moved PowerToysPeekProvider availability check after QuickLookProvider and SeerProProvider in GetProviderAsync. This alters the priority in which preview providers are selected.

commit 929c304
Author: Yair <[email protected]>
Date:   Sun Dec 14 10:19:27 2025 -0500

    Build: v4.0.22

    Signed-off-by: Yair <[email protected]>

commit 7def439
Author: Yair <[email protected]>
Date:   Wed Dec 10 18:19:38 2025 -0500

    Feature: Added support for PowerToys Peek (files-community#17954)

commit 6cca0bb
Author: Saravanan G <[email protected]>
Date:   Wed Dec 10 21:17:46 2025 +0530

    Fix: Fixed crash that would sometimes occur when resizing the window (files-community#17893)

commit e7eaf16
Author: Barton Milnor Mallory <[email protected]>
Date:   Tue Dec 9 18:24:54 2025 -0600

    Code Quality: Fixed typos in code comments (files-community#17945)

commit ddeb2ff
Author: Saravanan G <[email protected]>
Date:   Thu Dec 4 00:53:07 2025 +0530

    Fix: Fixed crash when switching git branches during merge conflict (files-community#17894)

    Signed-off-by: Saravanan G <[email protected]>
    Co-authored-by: Yair <[email protected]>

commit 4abd5f2
Author: Kalmix <[email protected]>
Date:   Wed Dec 3 11:34:58 2025 -0400

    Fix: Fixed PNG-based .ico files rendering with black backgrounds (files-community#17924)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready to merge Pull requests that are approved and ready to merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants